﻿<?php
// ------------------------------------------------------------------
// NEEDED STUBS FOR THIS EXAMPLE
// ------------------------------------------------------------------


// this will include all needed files to be able to build a Request
include_once($CONF["STUBS_FOLDER"]."Map24LocationService/Map24LocationService.php5");


// ------------------------------------------------------------------
// NEEDED PARAMETERS FOR THIS REQUEST
// ------------------------------------------------------------------


// the start address
$sStreet	= 'Düsseldorfer Str.';
$sZip		= '63571';
$sCity		= 'Eschborn';
$sCountry	= 'DE';


// the destination address
$dStreet	= 'Domtr.';
$dZip		= '50668';
$dCity		= 'Köln';
$dCountry	= 'DE';

$Offset = 0;
$Count = 10;
$Radius = 1000;

$LayerID = '10|11|12|13|14|15|16|17|18|19';

// Or search for Custom Layer IDs
// avalible LayerIDs: 7779|7778|7780|3509|3510|3511|3512|73|6926|74|75|76|77|5571|5572|5570|7779|7778|7780|6926|5362|8395|8398|8405|8396|8397|8402|8394|8401|8404|8399|8403|8400|7324|3563|5902|5900|5901|5621|9236|9121|9237|9120|9122|8992|8990|8991|3767|5606|5607|5636|5761|5997|7361|7362|7363|5571|5572|5570
// $CustomerLayerID='';


// ------------------------------------------------------------------
// BUILDING THE REQUEST
// ------------------------------------------------------------------


// definition of the request header with Map24ID and SessionID
$header = new RequestHeader();
$header->Map24ID  = $CONF['MAP24_ID'];
$header->ClientID = $CONF['SESSION_ID'];

// definition of the request body
$request= new FindInRouteCorridorRequest();
$request->Offset = $Offset;
$request->Count = $Count;
$request->Radius = $Radius;
$request->Map24LayerIDs = array($LayerID);
// Or search for Custom Layer IDs
// $request->CustomerLayerIDs=array($CustomerLayerID);
$request->MaxNoOfGeocodeAlternatives = $MaxNoOfGeocodeAlternatives;

// define the Start Address
$request->Start = new CoordinateAndAddress();
$request->Start->Address = new Address();
$request->Start->Address->Street = $sStreet;
$request->Start->Address->ZIP = $sZip;
$request->Start->Address->City = $sCity;
$request->Start->Address->Country = $sCountry;

// define the Destination Address
$request->Destination = new CoordinateAndAddress();
$request->Destination->Address = new Address();
$request->Destination->Address->Street = $dStreet;
$request->Destination->Address->ZIP = $dZip;
$request->Destination->Address->City = $dCity;
$request->Destination->Address->Country = $dCountry;


// ------------------------------------------------------------------
// EXECUTE THE REQUEST
// ------------------------------------------------------------------


// in this object the SoapClient will be initiated and executed
$maploc = new Map24LocationService($CONF['MAPTP_SYSTEM'],$CONF['MAP24_ID'],$CONF['SESSION_ID']);
$response = $maploc->findInRouteCorridor($header,$request);


// ------------------------------------------------------------------
// OUTPUT THE RESULT
// ------------------------------------------------------------------


$resultString = "";
$counter = 0;

if( isset($response->Route) )
{
	foreach ($response->Route->Segments[2]->Map24Locations as $loc)
	{
		$counter++;

		$resultString .= "<div style='border:1px solid black;margin:2px 0px;padding:5px;'>".$counter.". ";
		$resultString.= "<b>Name: " . $loc->Name1 ."</b><br />";
		$resultString.= "LocationID: " . $loc->LocationID ."<br />";
		$resultString.= "CustomerLocationID: " . $loc->CustomerLocationID ."<br />";
		$resultString.= "LayerID: " . $loc->LayerID ."<br />";
		$resultString.= "Longitude: " . $loc->LongitudeD ."<br />";
		$resultString.= "Latitude: " . $loc->Latitude ."<br />";
		$resultString.= "Description: " . $loc->Description ."<br />";
		$resultString .= "</div>";
	}
}
else
{
	$resultString = "Sorry, nothing found. Please try another Layer ID";
}


?>